package me.leiusual.sharing.repository.datasource

import androidx.lifecycle.MutableLiveData
import androidx.paging.DataSource
import me.leiusual.sharing.api.ApiSharing
import me.leiusual.sharing.api.model.UserMessage

/**
 * author: leiusual
 * create on: 2019-08-04
 * description:
 */
class UserMessageDataSourceFactory(
    private val apiSharing: ApiSharing
) : DataSource.Factory<Int, UserMessage>() {

  val userMessageDataSource = MutableLiveData<UserMessageDataSource>()

  override fun create(): DataSource<Int, UserMessage> {
    val dataSource = UserMessageDataSource(apiSharing)
    userMessageDataSource.postValue(dataSource)
    return dataSource
  }
}